<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm"  uri="http://www.springframework.org/tags/form"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.detail_tab{
	border-collapse: collapse;
	width:100%;
	margin:0px;
}
.detail_tab input[type='text']{
	width:160px;
	height: 18px;
	vertical-align: middle;
	border: 1px solid #b3d06c;
}
.detail_tab select{
	width:164px;
	height: 22px;
	vertical-align: middle;
	border: 1px solid #b3d06c;
}
.detail_tab td{
	height: 26px;
	line-height: 26px;
	border:1px solid #b3d06c;
}
.detail_feild{
	text-align: right;
	width:50%;
	color:#48f;
	padding:0;
	font-weight: bold;
}
.option_panel{
	text-align: center;
}
.option_panel a{
	font-size: 16px;
	color:blue;
}
.unchange{
	border:1px solid #222;
	background-color: #999;
	display: inline-block;
	width:160px;
	line-height:20px;
	height:20px;
	color:black;
}
</style>
<script type="text/javascript">
	var jsBase = "<%=basePath%>auth/user/";
	function crud(opt){
		switch (opt){
		case 'save':
		$("#userForm").attr("action",jsBase+"save.do").submit();
		break;
		case 'update':
		$("#userForm").attr("action",jsBase+"update.do").submit();
		break;
		}
	}
	function clean(){
		$("#userForm input[type='text']").each(function(){
			this.value="";
		});
	}
	function verifyLoginid(){
		var loginid = $("#loginid").attr("value");
		if(loginid==""){
			notice("_loginid","1", "*必须填写登录名");
			return;
		}
		notice("_loginid","3", "正在验证登录名["+loginid+"]是否已存在……");
		$.post(jsBase+"exists.do?loginid="+loginid, null, 
		function(data, status){
			data = eval(data);
			if(data == "1"){
				notice("_loginid","1", "*登录名["+loginid+"]已经存在，请换一个再尝试");
			}else{
				notice("_loginid","2", "");
			}
		});
	}
	function notice(id, type, msg){
		$("#"+id).html(msg);
		if(type == "1"){
			$("#"+id).css("color","red");
		}else if(type == "2"){
			$("#"+id).css("color","blue");
		}
	}
</script>
<title>用户信息-编辑</title>

<!-- JS与CSS引用 [START] -->
<%@include file="/WEB-INF/include/head-common.jsp" %>
<!-- JS与CSS引用 [END] -->

</head>
<body>
<div id="main_container">

	<!-- 网页顶部信息 [START] -->
	<%@include file="/WEB-INF/include/header.jsp" %> 
	<!-- 网页顶部信息 [END] -->
	
    
    <div class="main_content">
    	<!-- 网页顶部导航菜单 [START] -->
    	<%@include file="/WEB-INF/include/main-menu.jsp" %>
        <!-- 网页顶部导航菜单 [END] -->            
                    
    <div class="center_content">  
    
    
    
    <div class="left_content">
    
    
    		<!-- 网页左侧菜单 [START] -->
            <%@include file="/WEB-INF/include/sidebarmenu.jsp" %>
            <!-- 网页左侧菜单 [END] --> 
            
    </div>  
    
    <div class="right_content">
     
   			<h2>用户信息编辑</h2>  
	 		<div>
   			<fm:form modelAttribute="userinfo" id="userForm">
   			<fm:hidden path="pkUserinfo"/>
   			<table class="detail_tab">
   			<tr>
   				<td class="detail_feild">登录名：</td>
   				<td>
	   				<c:choose>
					<c:when test="${userinfo.pkUserinfo == null}">
						<fm:input path="loginid" onblur="verifyLoginid();"/>
						<span id="_loginid"></span>
					</c:when>
					<c:otherwise>
						<fm:hidden path="loginid"/>
						<span class="unchange">${userinfo.loginid}</span>*不能修改
					</c:otherwise>
		   			</c:choose>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">用户类型：</td>
   				<td>
   					<label><fm:radiobutton path="usertype" value="1" checked="checked"/>普通用户</label>
   					<label><fm:radiobutton path="usertype" value="2"/>管理员</label>
   					<%// 只有超级管理员才能添加[超级管理员]  %>
   					<c:if test="${sessionScope.logon_userinfo.usertype == '3'}">
   						<label><fm:radiobutton path="usertype" value="3"/>超级管理员</label>   					
   					</c:if>
   					
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">部门：</td>
   				<td>
   				<fm:select path="dept.pkDept">
				<c:forEach var="item" items="${depts}">
				<fm:option value="${item.pkDept}">${item.name}</fm:option>
				</c:forEach>
				</fm:select>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">是否可用：</td>
   				<td>
					<label><fm:radiobutton path="enabled" value="1" checked="checked"/>可用</label>
   					<label><fm:radiobutton path="enabled" value="0"/>禁用</label>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">电子邮件：</td>
   				<td>
   					<fm:input path="email"/>
   					<span id="_email"></span>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">联系电话：</td>
   				
   				<td>
   					<fm:input path="tellphone"/>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">真实姓名：</td>
   				<td>
   					<fm:input path="realname"/>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">添加时间：</td>
   				<td>
   					<fm:hidden path="adddatetime"/>
   					<span class="unchange">${userinfo.adddatetime}</span>
   				</td>
   			</tr>
   			<tr>
   				<td class="detail_feild">修改时间：</td>
   				<td>
   					<fm:hidden path="moddatetime"/>
   					<span class="unchange">${userinfo.moddatetime}</span>
   				</td>
   			</tr>
   			</table>

   			<div class="option_panel">
   			<c:choose>
			<c:when test="${userinfo.pkUserinfo == null}">
				<input type="button" value="保存" onclick="crud('save')"/>
			</c:when>
			<c:otherwise>
				<input type="button" value="保存" onclick="crud('update')"/>
			</c:otherwise>
   			</c:choose>
   				<input type="button" value="重置" onclick="clean()"/>
   				<input type="button" value="返回列表" onclick="location.href='<%=basePath %>auth/user.do'"/>
   			</div>
   			</fm:form> 
    		</div>     
    			    
     </div>
     <!-- end of right content-->
            
                    
  </div>   
  <!--end of center content -->               
                    
                    
    
    
    <div class="clear"></div>
    </div> <!--end of main content-->
	
    
    <div class="footer">
    
    	<div class="left_footer">IN ADMIN PANEL | Powered by <a href="http://indeziner.com">INDEZINER</a></div>
    	<div class="right_footer"><a href="http://indeziner.com"><img src="images/indeziner_logo.gif" alt="" title="" border="0" /></a></div>
    
    </div>

</div>		
</body>
</html>